using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FlatRedBall;
using FlatRedBall.Graphics;
using FlatRedBall.Input;

using MiJuego.Screens;

namespace MiJuego
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
		CollisionManager col = CollisionManager.getInstance();
        
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 600;
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            Renderer.UseRenderTargets = false;
            FlatRedBallServices.InitializeFlatRedBall(this, graphics);

            Scene scene = FlatRedBallServices.Load<Scene>("level.scnx");
            scene.AddToManagers();

            Sprite sp_player = scene.Sprites.FindByName("nave1");
            Player player = new Player(this, sp_player );
            this.Components.Add(player);

            Boss1 boss = new Boss1(this);
            this.Components.Add(boss);

            Sprite enemy2 = scene.Sprites.FindByName("enemigo2");
            Enemigosimple enemigo2 = new Enemigosimple(this, enemy2, player);
            enemy2.YVelocity = 15;
            enemy2.XVelocity = -8;
            enemy2.YAcceleration = -20;
            enemy2.XAcceleration = 7;

            Sprite enemy3 = scene.Sprites.FindByName("enemigo3");
            enemy3.YVelocity = 15;
            enemy3.XVelocity = 8;
            enemy3.YAcceleration = -20;
            enemy3.XAcceleration = -7;
            
			col.AddRuleCollision(2, 3);
            col.AddRuleCollision(1, 3);

            //ScreenManager.Start(typeof(SomeScreen).FullName);

            

           
                                   


            base.Initialize();
        }


        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            
            FlatRedBallServices.Update(gameTime);

            ScreenManager.Activity();

            col.Update();
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            FlatRedBallServices.Draw();

            base.Draw(gameTime);
        }
    }
}
